/*
* This file is part of RoboDS (http://code.google.com/p/robods/)
* Copyright (C) 2007 Blakharaz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
*/

#include "DsPrepareRoundState.h"

#include "Card.h"
#include "DsCard.h"
#include "DsGame.h"
#include "DsSprite.h"
#include "RobotController.h"

namespace robo
{

    DsPrepareRoundState::DsPrepareRoundState(DsGame* game)
    : PrepareRoundState(game)
    {
    }

    DsPrepareRoundState::~DsPrepareRoundState()
    {
    }

    void DsPrepareRoundState::handleEvents()
    {
        CardSet lst;
        lst.insert(new DsCard(Card::CARD_MOVEMENT_3, 760, DsSprite::SPRITE_CARD_MOVEMENT_3));
        lst.insert(new DsCard(Card::CARD_MOVEMENT_2, 580, DsSprite::SPRITE_CARD_MOVEMENT_2));
        lst.insert(new DsCard(Card::CARD_MOVEMENT_1, 300, DsSprite::SPRITE_CARD_MOVEMENT_1));
        lst.insert(new DsCard(Card::CARD_MOVEMENT_BACK, 150, DsSprite::SPRITE_CARD_MOVEMENT_BACK));
        lst.insert(new DsCard(Card::CARD_TURN_LEFT, 80, DsSprite::SPRITE_CARD_TURN_LEFT));
        lst.insert(new DsCard(Card::CARD_TURN_RIGHT, 70, DsSprite::SPRITE_CARD_TURN_RIGHT));
        lst.insert(new DsCard(Card::CARD_TURN_AROUND, 30, DsSprite::SPRITE_CARD_TURN_AROUND));
        lst.insert(new DsCard(Card::CARD_MOVEMENT_1, 280, DsSprite::SPRITE_CARD_MOVEMENT_1));
        lst.insert(new DsCard(Card::CARD_MOVEMENT_BACK, 120, DsSprite::SPRITE_CARD_MOVEMENT_BACK));
        lst.insert(new DsCard(Card::CARD_TURN_LEFT, 60, DsSprite::SPRITE_CARD_TURN_LEFT));
        
	    for (std::vector<RobotController*>::const_iterator it = mControllers.begin();
		    it != mControllers.end(); ++it)
	    {
		    RobotController* cur = *it;
		    cur->clear();
		    cur->setAvailableCards(lst);
		    cur->update();
	    }

	    switchGameState(GameState::USER_INPUT);
    }

} // namespace robo
